import React, { Component } from "react"
import  { Link, browserHistory } from 'react-router'
import fetchData from '../../util/fetch'
import { Tabs, Carousel, Row, Col } from 'antd'


var ReactDOM = require("react-dom");
const TabPane = Tabs.TabPane;
import { getUrl } from '../../util/function'

import '../../style/activity/activityItem.scss'
class activityItem extends React.Component {
	constructor(props) { // 
		super(props)
		this.state = {
			itemId:this.props.params.id,// itemId 
			banner: null,
			newsItem:null, // 新闻详情
		}
	}
	
	getDataById(url, opts) {
		fetchData(url, opts, function (res) {
			let data = eval(res.data)
			this.setState({
				newsItem:data
			})
		}.bind(this))
		
	}
	
	getBannerData(url, opts) { // 请求banner
		fetchData(url, opts, function (res) {
			let data = eval(res.data);
			this.setState({
				banner: data
			});
		}.bind(this));
	}
	
	componentDidMount() {

		this.getBannerData('/crm/api/v1/web/banner/findOneByType', { "dataId": 4 });
		this.getDataById('/crm/api/v1/web/news/findOneById', { "dataId": 268});
		console.log(this.state.itemId)
	}

	

	render() {
		

		return (
			<div className="activity">
				<div className="activity-banner"><img src={this.state.banner ? this.state.banner.imgUrl : null}/></div>
				<div className="activityItem">
					<div className="activityItemTitle">
						<div>当前位置 : 首页 > 活动咨讯 > 新闻动态 > 列表 > {this.state.newsItem ? this.state.newsItem.title : null}</div>
					</div>
					<div className="activityItemCenter">
						<div className="activityCenterTop">{this.state.newsItem ? this.state.newsItem.title : null}</div>
						<div  dangerouslySetInnerHTML={{__html:this.state.newsItem ? this.state.newsItem.content : null}}></div>
					</div>
					<div className="activityItemBottom">
						<div className="activityBottomPrev"> <Link  to={`:${this.state.newsItem ? this.state.newsItem.prevId :null}`}>上一篇 : {this.state.newsItem ? this.state.newsItem.prevTitle :null }</Link></div>
						<div className="activityBottomNext"> <Link  to={`:${this.state.newsItem ? this.state.newsItem.nextId :null}`}>下一篇 : {this.state.newsItem ? this.state.newsItem.nextTitle :null }</Link> </div>
					</div>
				</div>
			</div>
		)
	}
}


export default activityItem ;
